package com.dd.seckill.cluster.config.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
@author Liu Xianmeng
@createTime 2023/6/3 21:29
@instruction 生产者
*/
@Service
@Slf4j
public class MQSeckillMsgSender {

    @Autowired
    RabbitTemplate rabbitTemplate;

    //发送秒杀信息
    public void senderMessage(String seckillMessage) {
        log.info("发送消息：" + seckillMessage.toString());
        rabbitTemplate.convertAndSend(
            MQSecKillConfig.EXCHANGE, // 指定发送给哪个交换机
            MQSecKillConfig.ROUTE,  // 指定发送给哪个路由
            seckillMessage  // 指定发送的消息实体
        );
    }
}
